package com.foreveross.fetl.core.domain.freight;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.foreveross.fetl.common.domain.BaseEntity;
import com.foreveross.fetl.core.domain.freight.repository.ICsairReportRepository;

@Entity
@Table(name="csair_report")
public class CsairReport extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6854025321362931086L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	/**
	 * 报表日期  2014-01-01
	 */
	@Column(name="REPROT_DATE")
	private Date reportDate;
	
	/**
	 * 航班日期 2014-01-01
	 */
	@Column(name="FLIGHT_DATE")
	private Date flightDate;
	
	/**
	 * 航班类型 0单程，1往返
	 */
	@Column(name="FLIGHT_TYPE")
	private int flightType;
	
	/**
	 * 出发城市三字码
	 */
	@Column(name="FROM_CITY")
	private String fromCity;
	
	/**
	 * 出发城市名称
	 */
	@Column(name="FROM_CITY_NAME")
	private String fromCityName;
	
	/**
	 * 到达城市三字码
	 */
	@Column(name="TO_CITY")
	private String toCity;
	
	/**
	 * 到达城市名称
	 */
	@Column(name="TO_CITY_NAME")
	private String toCityName;
	
	/**
	 * 航班号，单程 CZ1234 往返 CZ1234-CZ4321
	 */
	@Column(name="FLIGHT_NO")
	private String flightNo;
	
	/**
	 * B2C价格
	 */
	@Column(name="PRICE")
	private Double price;
	
	/**
	 * 淘宝价格
	 */
	@Column(name="TAOBAO_PRICE")
	private Double taobaoPrice;
	
	/**
	 * 淘宝代理商名称
	 */
	@Column(name="TAOBAO_AGENT_NAME")
	private String taobaoAgentName;
	
	/**
	 * 淘宝代理商地址
	 */
	@Column(name="TAOBAO_AGENT_ADDRESS")
	private String taobaoAgentAddress;
	
	/**
	 * 淘宝与官网价差金额  官网-淘宝
	 */
	@Column(name="TAOBAO_SPREAD_AMOUNT")
	private Double taobaoSpreadAmount;
	
	/**
	 * 淘宝价差  （官网-淘宝）/官网*100%，小数点后保留2位 1.13%  0.0113；
	 */
	@Column(name="TAOBAO_SPREAD")
	private Double taobaoSpread;
	
	/**
	 * 去哪儿价格
	 */
	@Column(name="QUNAR_PRICE")
	private Double qunarPrice;
	
	/**
	 * 去哪儿代理商名称
	 */
	@Column(name="QUNAR_AGENT_NAME")
	private String qunarAgentName;
	
	/**
	 * 去哪儿代理商地址
	 */
	@Column(name="QUNAR_AGENT_ADDRESS")
	private String qunarAgentAddress;
	
	/**
	 * 去哪儿与官网价差金额 官网-去哪儿
	 */
	@Column(name="QUNAR_SPREAD_AMOUNT")
	private Double qunarSpreadAmount;
	
	
	/**
	 * 去哪儿价差 （官网-去哪儿）/官网*100%，小数点后保留2位 1.13%；
	 */
	@Column(name="QUNAR_SPREAD")
	private Double qunarSpread;
	
	/**
	 * 抓取时间
	 */
	@Column(name="GRAB_TIME")
	private Date grabTime;
	
	/**
	 * 国内&&国际    1国内航线   2国际航线
	 */
	@Column(name="WEB_TYPE")
	private int webType;
	
	@Column(name="HBASE_KEY")
	private String hbaseKey;
	
	@Column(name="CHANNEL")
	private String channel;
	
	@Column(name="GRAB_HBASE_KEY")
	private String grabHbaseKey;
	
	@Column(name="GRAB_CHANNEL")
	private String grabChannel;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getReportDate() {
		return reportDate;
	}

	public void setReportDate(Date reportDate) {
		this.reportDate = reportDate;
	}

	public Date getFlightDate() {
		return flightDate;
	}

	public void setFlightDate(Date flightDate) {
		this.flightDate = flightDate;
	}

	public int getFlightType() {
		return flightType;
	}

	public void setFlightType(int flightType) {
		this.flightType = flightType;
	}

	public String getFromCity() {
		return fromCity;
	}

	public void setFromCity(String fromCity) {
		this.fromCity = fromCity;
	}

	public String getFromCityName() {
		return fromCityName;
	}

	public void setFromCityName(String fromCityName) {
		this.fromCityName = fromCityName;
	}

	public String getToCity() {
		return toCity;
	}

	public void setToCity(String toCity) {
		this.toCity = toCity;
	}

	public String getToCityName() {
		return toCityName;
	}

	public void setToCityName(String toCityName) {
		this.toCityName = toCityName;
	}

	public String getFlightNo() {
		return flightNo;
	}

	public void setFlightNo(String flightNo) {
		this.flightNo = flightNo;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Double getTaobaoPrice() {
		return taobaoPrice;
	}

	public void setTaobaoPrice(Double taobaoPrice) {
		this.taobaoPrice = taobaoPrice;
	}

	public String getTaobaoAgentName() {
		return taobaoAgentName;
	}

	public void setTaobaoAgentName(String taobaoAgentName) {
		this.taobaoAgentName = taobaoAgentName;
	}

	public String getTaobaoAgentAddress() {
		return taobaoAgentAddress;
	}

	public void setTaobaoAgentAddress(String taobaoAgentAddress) {
		this.taobaoAgentAddress = taobaoAgentAddress;
	}

	public Double getTaobaoSpreadAmount() {
		return taobaoSpreadAmount;
	}

	public void setTaobaoSpreadAmount(Double taobaoSpreadAmount) {
		this.taobaoSpreadAmount = taobaoSpreadAmount;
	}

	public Double getTaobaoSpread() {
		return taobaoSpread;
	}

	public void setTaobaoSpread(Double taobaoSpread) {
		this.taobaoSpread = taobaoSpread;
	}

	public Double getQunarPrice() {
		return qunarPrice;
	}

	public void setQunarPrice(Double qunarPrice) {
		this.qunarPrice = qunarPrice;
	}

	public String getQunarAgentName() {
		return qunarAgentName;
	}

	public void setQunarAgentName(String qunarAgentName) {
		this.qunarAgentName = qunarAgentName;
	}

	public String getQunarAgentAddress() {
		return qunarAgentAddress;
	}

	public void setQunarAgentAddress(String qunarAgentAddress) {
		this.qunarAgentAddress = qunarAgentAddress;
	}

	public Double getQunarSpreadAmount() {
		return qunarSpreadAmount;
	}

	public void setQunarSpreadAmount(Double qunarSpreadAmount) {
		this.qunarSpreadAmount = qunarSpreadAmount;
	}

	public Double getQunarSpread() {
		return qunarSpread;
	}

	public void setQunarSpread(Double qunarSpread) {
		this.qunarSpread = qunarSpread;
	}

	public Date getGrabTime() {
		return grabTime;
	}

	public void setGrabTime(Date grabTime) {
		this.grabTime = grabTime;
	}
	
	

	public String getHbaseKey() {
		return hbaseKey;
	}

	public void setHbaseKey(String hbaseKey) {
		this.hbaseKey = hbaseKey;
	}



	public String getChannel() {
		return channel;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}
	
	

	public String getGrabHbaseKey() {
		return grabHbaseKey;
	}

	public void setGrabHbaseKey(String grabHbaseKey) {
		this.grabHbaseKey = grabHbaseKey;
	}

	public String getGrabChannel() {
		return grabChannel;
	}

	public void setGrabChannel(String grabChannel) {
		this.grabChannel = grabChannel;
	}

	public int getWebType() {
		return webType;
	}

	public void setWebType(int webType) {
		this.webType = webType;
	}

	public ICsairReportRepository getICsairReportRepository(){
		return InstanceFactory.getInstance(ICsairReportRepository.class);
	}
	
	public void saveOrUpdate(CsairReport csairReport){
		getICsairReportRepository().saveOrUpdate(csairReport);
	}
	
	/**
	 * 根据条件查找条记录
	 * @param reportDate 报表日期 yyyy-MM-dd
	 * @param flightDate 航班时间 yyyy-MM-dd
	 * @param flightType 航班类型 0 单程 1 往返
	 * @param fromCity   出发城市三字码
	 * @param toCity     到达城市三字码
	 * @param flightNo   航班号
	 * @return
	 */
	public List<CsairReport> findByCondition(Date reportDate, Date flightDate,
			int flightType, String fromCity, String toCity, String flightNo){
		return getICsairReportRepository().findByCondition(reportDate, flightDate, flightType, fromCity, toCity, flightNo,null);
	}
	
	public CsairReport findById(Long id){
		return getICsairReportRepository().findById(id);
	}
	
	public int createReport(List<String> airCompanys,List<String> chanels,String formCity,String toCity,Date reportDate, Date flightDate,int webType,int flighType){
		 return getICsairReportRepository().createReport(airCompanys,chanels, formCity, toCity, reportDate, flightDate, webType, flighType);
	}
	public int createDouble(List<String> chanels,String formCity,String toCity,Date reportDate, Date flightDate,int webType){
		return getICsairReportRepository().createDouble(chanels, formCity, toCity, reportDate, flightDate,webType);
	}

}
